﻿Public Partial Class Wctl_Usuario
    Inherits WCtl_Master
    Dim mensajeCrear As String = "¿Esta Seguro de Crear un Nuevo Usuario?"
    Dim MensajeModificar As String = "¿Esta Seguro de Modificar el Usuario?"
    Dim Tabla As String = "TB_EST_USUARIO"

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        '    function CargarCalendario()
        '{		  
        '		$(function() {$("#Txt_FechaFacturaGuia").datepicker({altField: '#alternate', altFormat: 'DD, d MM, yy'});	});
        '	}
        Anthem.Manager.Register(Me)
        Anthem.Manager.AddScriptForClientSideEval("$('.rounded').corners();")

        'Anthem.Manager.AddScriptForClientSideEval("CargarCalendario(" & d_fecha_vigencia.ClientID & ")")





    End Sub

    Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click

        If ImageButton1.ImageUrl = "~/images/collapse_blue.jpg" Then
            ImageButton1.ImageUrl = "~/images/expand_blue.jpg"
            ImageButton1.UpdateAfterCallBack = True

            Panel1.Visible = False
            Panel1.UpdateAfterCallBack = True
        Else
            ImageButton1.ImageUrl = "~/images/collapse_blue.jpg"
            ImageButton1.UpdateAfterCallBack = True

            Panel1.Visible = True
            Panel1.UpdateAfterCallBack = True
        End If

    End Sub

    Protected Sub ImageButton5_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles img_continuar_accion.Click
        pnl_mensaje.Visible = False
        pnl_mensaje.UpdateAfterCallBack = True

        If ViewState("opcion") = "G" Then
            GrabarRegistro()
        End If

        ViewState("opcion") = ""

    End Sub

    Protected Sub img_grabar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles img_grabar.Click
        If Session("usuario") Is Nothing Then
            Exit Sub
        End If

        pnl_mensaje.Visible = True
        img_continuar_accion.Visible = True
        img_continuar_accion.UpdateAfterCallBack = True


        ViewState("opcion") = "G"
        If Val(p_usuario.Text) = "0" Then
            Me.lbl_mensaje.Text = mensajeCrear
        Else
            Me.lbl_mensaje.Text = MensajeModificar
        End If

        pnl_mensaje.UpdateAfterCallBack = True
        lbl_mensaje.UpdateAfterCallBack = True

    End Sub

    Protected Sub img_cancelar_accion_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles img_cancelar_accion.Click
        pnl_mensaje.Visible = False
        pnl_mensaje.UpdateAfterCallBack = True
    End Sub

    Sub GrabarRegistro()
        Dim rp As New DotNetResponse.SQLPersistence

        If Val(p_usuario.Text) = "0" Then
            Dim Save As New DalAppTestBuilder.TB_GENERICA   ' ClsMantenedor
            'Save.CrearRegistro(Me.tbl_ingreso_datos, Tabla)
            Save.Save(rp, tbl_ingreso_datos, Val(p_usuario.Text), "p_usuario", False)

        End If


    End Sub
    Sub ShowError(ByVal Mensaje As String)

    End Sub

    Protected Sub img_buscar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles img_buscar.Click
        Buscar_CargarGrilla(txt_busqueda.Text.Trim)

    End Sub

#Region "Porpio de la tabla usuarios"

    Sub Buscar_CargarGrilla(ByVal texto As String)
        Dim csql As String
        csql = " SELECT  [P_USUARIO]"
        csql = csql & " ,[S_LOGIN]"
        csql = csql & " ,[S_CLAVE_DISEÑO]"
        csql = csql & " ,[S_CLAVE_ADMINISTRACION]"
        csql = csql & " ,[D_FECHA_VIGENCIA]"
        csql = csql & " ,[S_EMAIL]"
        csql = csql & " ,[K_ESTABLECIMIENTO]"
        csql = csql & " ,[K_TIPO_USUARIO]"
        csql = csql & " FROM [TESTBUILDER_000].[dbo].[TB_EST_USUARIO]"
        csql = csql & " where  s_login like '%" & texto & "%'"

        Dim GetGrid As New DalAppTestBuilder.TB_GENERICA
        Dim rp As New DotNetResponse.SQLPersistence

        GetGrid.CargarGrilla(rp, Dg_Datos, csql)

        Dg_Datos.UpdateAfterCallBack = True

    End Sub
#End Region

    Protected Sub img_limpiar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles img_limpiar.Click
        'ClearObject
        Dim Clear As New DalAppTestBuilder.TB_GENERICA
        Clear.ClearObject(tbl_ingreso_datos)


    End Sub

    Protected Sub img_calendario_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles img_calendario.Click
        Calendar1.Visible = Not Calendar1.Visible
        Calendar1.UpdateAfterCallBack = True
    End Sub

    Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Calendar1.SelectionChanged
        d_fecha_vigencia.Text = Calendar1.SelectedDate
        Calendar1.SelectedDate = Nothing
        d_fecha_vigencia.UpdateAfterCallBack = True
        Calendar1.Visible = False
        Calendar1.UpdateAfterCallBack = True
    End Sub
End Class